package com.liuche.homechat.common.user.service.handler;

import com.liuche.homechat.common.user.service.WXMsgService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Slf4j
public class ScanHandler extends AbstractHandler {
    @Autowired
    private WXMsgService wxMsgService;

    /**
     * 用户扫描二维码消息通知处理
     *
     * @param wxMpXmlMessage
     * @param map
     * @param wxMpService
     * @param wxSessionManager
     * @return
     */
    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
                                    WxMpService wxMpService, WxSessionManager wxSessionManager) {
        // 扫码事件处理
        log.info("接收到用户的扫码，wxMpXmlMessage->[{}],map->[{}]", wxMpXmlMessage, map);
        return wxMsgService.handleScan(wxMpXmlMessage, map, wxMpService, wxSessionManager);
    }

}
